package cn.melonlib.cores.identification.comp.messenger.impl;

import cn.hutool.core.lang.UUID;
import cn.melonlib.cores.identification.comp.messenger.IdentificationMessenger;
import cn.melonlib.cores.identification.model.entity.Identification;
import cn.melonlib.cores.identification.model.entity.Organization;
import lombok.Getter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

/**
 * 虚构的身份认证信息，一般用来测试接口调用或者无认证模块时使用
 */
@Component
@ConditionalOnProperty(value = "security.auth.mode",havingValue = "invented",matchIfMissing = true)
public class IdentificationMessengerInvented implements IdentificationMessenger {

    private final InventedIdentification identification=new InventedIdentification();

    @Override
    public InventedIdentification getIdentification() {
        return identification;
    }

    @Override
    public Organization getOrganization() {
        return identification.getOrganization();
    }

    @Override
    public String getToken() {
        return identification.token;
    }


    @Getter
    public static class InventedIdentification implements Identification<String> {

        private final String id = "1";

        private final String account = "InnerTestUser";

        private final String name = "内部测试用户";

        private final Long loginTime = System.currentTimeMillis();

        private final Organization organization = new InventedOrganization();

        private final String token= UUID.fastUUID().toString();

        private final String openid="1";
    }

    @Getter
    public static class InventedOrganization implements Organization<String>{

        private final String id = "2";

        private final String code="InnerTestOrganization";

        private final String name="内部测试组织机构";

        private final String phone="7758258";

        private final String email="inner_test_organization@melonlib.cn";

    }
}
